```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Zookeeper 集群部署指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
        }
        .code-block {
            background: #2d2d2d;
            color: #f8f8f2;
            border-radius: 0.5rem;
            overflow: hidden;
        }
        .code-header {
            background: #1e1e1e;
            padding: 0.5rem 1rem;
            color: #ccc;
            font-size: 0.875rem;
            display: flex;
            justify-content: space-between;
        }
        .code-content {
            padding: 1rem;
            font-family: 'Courier New', Courier, monospace;
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .section-divider {
            border: none;
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6">Zookeeper 集群部署指南</h1>
                <p class="text-xl md:text-2xl opacity-90 mb-8">掌握高可用分布式协调服务的部署与管理</p>
                <div class="flex justify-center space-x-4">
                    <a href="#deployment" class="px-6 py-3 bg-white text-purple-700 font-medium rounded-lg hover:bg-opacity-90 transition-all">
                        <i class="fas fa-rocket mr-2"></i>立即部署
                    </a>
                    <a href="#best-practices" class="px-6 py-3 bg-opacity-20 border border-white font-medium rounded-lg hover:bg-opacity-30 transition-all">
                        <i class="fas fa-lightbulb mr-2"></i>最佳实践
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12 max-w-5xl">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="prose max-w-full">
                <h2 class="text-3xl font-bold mb-6 text-gray-800">Zookeeper 集群概述</h2>
                <p>Zookeeper 是一个分布式的、开放源码的分布式应用程序协调服务，是 Google 的 Chubby 一个开源的实现。它提供了一组简单的原语，分布式应用程序可以基于这些原语实现更高层次的服务，如同步、配置维护、分组和命名。</p>
                <p>在生产环境中，Zookeeper 通常需要以集群模式部署，以确保高可用性和数据一致性。本指南将详细介绍如何使用 Docker 部署一个高可用的 Zookeeper 集群。</p>
                
                <div class="mt-8">
                    <div class="mermaid">
                        graph TD
                            A[客户端] --> B[Zookeeper集群]
                            B --> C[Leader]
                            B --> D[Follower]
                            B --> E[Follower]
                            C -->|心跳| D
                            C -->|心跳| E
                            D -->|同步请求| C
                            E -->|同步请求| C
                    </div>
                </div>
            </div>
        </section>

        <hr class="section-divider my-12">

        <!-- Deployment Steps -->
        <section id="deployment" class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800">部署步骤</h2>
            
            <!-- Step 1 -->
            <div class="card bg-white rounded-xl p-6 mb-8">
                <div class="flex items-center mb-4">
                    <div class="flex items-center justify-center w-10 h-10 rounded-full bg-purple-100 text-purple-700 font-bold mr-4">1</div>
                    <h3 class="text-xl font-semibold">创建 Docker 网络</h3>
                </div>
                <p class="text-gray-600 mb-4">为了确保 Zookeeper 实例之间的网络通信正常，需要创建一个自定义 Docker 网络：</p>
                <div class="code-block">
                    <div class="code-header">
                        <span>终端命令</span>
                        <button class="copy-btn text-xs opacity-70 hover:opacity-100">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <div class="code-content">docker network create zookeeper-network</div>
                </div>
            </div>
            
            <!-- Step 2 -->
            <div class="card bg-white rounded-xl p-6 mb-8">
                <div class="flex items-center mb-4">
                    <div class="flex items-center justify-center w-10 h-10 rounded-full bg-purple-100 text-purple-700 font-bold mr-4">2</div>
                    <h3 class="text-xl font-semibold">配置 Zookeeper 容器</h3>
                </div>
                <p class="text-gray-600 mb-4">使用 Docker Compose 配置 Zookeeper 集群。创建一个 <code>docker-compose.yml</code> 文件：</p>
                <div class="code-block mb-4">
                    <div class="code-header">
                        <span>docker-compose.yml</span>
                        <button class="copy-btn text-xs opacity-70 hover:opacity-100">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <div class="code-content">
version: '3'
services:
  zookeeper:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

  zookeeper1:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper1
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

  zookeeper2:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper2
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

  zookeeper3:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper3
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

networks:
  zookeeper-network:
    driver: bridge
                    </div>
                </div>
                <p class="text-gray-600">这个配置文件定义了一个包含三个 Zookeeper 实例的集群。<code>ZOO_MY_ID</code> 用于指定每个 Zookeeper 实例的 ID，<code>ZOO_SERVERS</code> 用于指定集群中的其他服务器。</p>
            </div>
            
            <!-- Step 3 -->
            <div class="card bg-white rounded-xl p-6 mb-8">
                <div class="flex items-center mb-4">
                    <div class="flex items-center justify-center w-10 h-10 rounded-full bg-purple-100 text-purple-700 font-bold mr-4">3</div>
                    <h3 class="text-xl font-semibold">启动 Zookeeper 集群</h3>
                </div>
                <p class="text-gray-600 mb-4">使用 Docker Compose 启动 Zookeeper 集群：</p>
                <div class="code-block">
                    <div class="code-header">
                        <span>终端命令</span>
                        <button class="copy-btn text-xs opacity-70 hover:opacity-100">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <div class="code-content">docker-compose up -d</div>
                </div>
            </div>
            
            <!-- Step 4 -->
            <div class="card bg-white rounded-xl p-6">
                <div class="flex items-center mb-4">
                    <div class="flex items-center justify-center w-10 h-10 rounded-full bg-purple-100 text-purple-700 font-bold mr-4">4</div>
                    <h3 class="text-xl font-semibold">验证集群状态</h3>
                </div>
                <p class="text-gray-600 mb-4">确保所有 Zookeeper 实例都正常运行，并且它们能够相互通信。可以通过访问 Zookeeper 的客户端工具进行验证：</p>
                <div class="code-block mb-4">
                    <div class="code-header">
                        <span>终端命令</span>
                        <button class="copy-btn text-xs opacity-70 hover:opacity-100">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <div class="code-content">docker exec -it zookeeper1 zkCli.sh</div>
                </div>
                <p class="text-gray-600">在 Zookeeper 客户端中执行 <code>stat</code> 命令来检查集群状态：</p>
                <div class="code-block">
                    <div class="code-header">
                        <span>Zookeeper CLI</span>
                    </div>
                    <div class="code-content">stat</div>
                </div>
            </div>
        </section>

        <hr class="section-divider my-12">

        <!-- Best Practices -->
        <section id="best-practices" class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800">最佳实践</h2>
            
            <div class="grid md:grid-cols-2 gap-6">
                <!-- Practice 1 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center mr-4">
                            <i class="fas fa-database text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">数据持久化</h3>
                    </div>
                    <p class="text-gray-600">配置 Zookeeper 容器的数据持久化，以避免数据丢失。可以通过 Docker 的数据卷将 Zookeeper 数据持久化到主机：</p>
                    <div class="code-block mt-4">
                        <div class="code-header">
                            <span>docker-compose.yml 片段</span>
                        </div>
                        <div class="code-content">
volumes:
  - /path/on/host/zookeeper/data:/data
  - /path/on/host/zookeeper/datalog:/datalog
                        </div>
                    </div>
                </div>
                
                <!-- Practice 2 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center mr-4">
                            <i class="fas fa-microchip text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">资源限制</h3>
                    </div>
                    <p class="text-gray-600">配置适当的资源限制（如内存和 CPU）以确保 Zookeeper 容器不会消耗过多资源：</p>
                    <div class="code-block mt-4">
                        <div class="code-header">
                            <span>docker-compose.yml 片段</span>
                        </div>
                        <div class="code-content">
deploy:
  resources:
    limits:
      cpus: "0.5"
      memory: "512M"
                        </div>
                    </div>
                </div>
                
                <!-- Practice 3 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center mr-4">
                            <i class="fas fa-chart-line text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">监控和日志</h3>
                    </div>
                    <p class="text-gray-600">配置 Zookeeper 容器的日志收集和监控，以便能够及时发现和解决问题。可以将日志输出到宿主机的目录：</p>
                    <div class="code-block mt-4">
                        <div class="code-header">
                            <span>docker-compose.yml 片段</span>
                        </div>
                        <div class="code-content">
logging:
  driver: "json-file"
  options:
    max-size: "10m"
    max-file: "3"
                        </div>
                    </div>
                </div>
                
                <!-- Practice 4 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center mr-4">
                            <i class="fas fa-shield-alt text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">高可用性</h3>
                    </div>
                    <p class="text-gray-600">确保集群中有足够的节点以实现高可用性。建议至少使用奇数个节点（如 3 或 5 个节点），以便在发生节点故障时仍能维持多数节点的选举。</p>
                </div>
                
                <!-- Practice 5 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center mr-4">
                            <i class="fas fa-network-wired text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">网络配置</h3>
                    </div>
                    <p class="text-gray-600">确保所有 Zookeeper 节点在同一个 Docker 网络中，以便它们能够相互发现和通信。网络配置应足够稳定，避免网络分区问题。</p>
                </div>
                
                <!-- Practice 6 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-700 flex items-center justify-center mr-4">
                            <i class="fas fa-lock text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">安全配置</h3>
                    </div>
                    <p class="text-gray-600">配置适当的安全设置，如启用 TLS/SSL 和认证机制，以保护 Zookeeper 集群免受未授权访问。</p>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto px-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-medium text-white mb-2">技术小馆</h3>
                    <p class="text-sm">专业的技术分享与学习平台</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-purple-300 hover:text-white transition-colors" target="_blank">
                        <i class="fas fa-external-link-alt mr-1"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'dark',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
        
        // Copy button functionality
        document.querySelectorAll('.copy-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                const codeContent = this.parentElement.nextElementSibling.textContent;
                navigator.clipboard.writeText(codeContent.trim()).then(() => {
                    const originalText = this.innerHTML;
                    this.innerHTML = '<i class="fas fa-check mr-1"></i>已复制';
                    setTimeout(() => {
                        this.innerHTML = originalText;
                    }, 2000);
                });
            });
        });
    </script>
</body>
</html>
```